/**
 * 类型集合
 */
const types =
  "Array Object String Date RegExp Function Boolean Number Null Undefined".split(
    " "
  );

/**
 *
 * @param {*} target
 * @returns
 */
export function typeJudge(target) {
  function type(target) {
    return Object.prototype.toString.call(target).slice(8, -1);
  }

  let judge = {};

  for (let i = types.length; i--; ) {
    judge["is" + types[i]] = function (elem) {
      return type(elem) === types[i];
    };
  }

  return judge;
}
